package com.mallify.admin.controller;

import com.mallify.admin.entity.vo.ValidateCode;
import com.mallify.admin.service.ValidateCodeService;
import com.mallify.common.response.Result;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *  验证码服务
 *  +----------------------------------------------------------------------
 *  | HANSON [ HANSON赋能开发者，助力企业发展 ]
 *  +----------------------------------------------------------------------
 *  | Licensed HANSON并不是自由软件，未经许可不能去掉HANSON相关版权
 *  +----------------------------------------------------------------------
 *  | Author: HANSON Team <hanson0622@126.com>
 *  +----------------------------------------------------------------------
 */
@Slf4j
@RestController
@RequestMapping("api/admin/validate/code")
public class ValidateCodeController {

    @Resource
    private ValidateCodeService validateCodeService;

    /**
     * 获取图片验证码
     * @return CommonResult
     */
//    @PreAuthorize("hasAuthority('admin:validate:code:get')")
    @ApiOperation(value="获取验证码")
    @GetMapping(value = "/get")
    public Result<ValidateCode> get() {
        ValidateCode validateCode = validateCodeService.get();
        return Result.success(validateCode);
    }
}